##Alison E. Post##
##Foreign and Domestic Investment in Argentina (2014)##
##Replication Code for Chapter 7, "Foreign and Domestic Investment in Argentina###

library(foreign)
library(survival)
library(Zelig)
library(car)

##load replication data set##
foreign_dom <- read.csv("replication.cross.section.csv", header=TRUE) 

##Create subset of data with just concessions and divestitures##
div.con <- foreign_dom[foreign_dom$Type_PPI!="Greenfield Project",]
div.con <- div.con[div.con$Type_PPI!="Management, Lease Contract",] 

###Histogram: Ownership variable###
hist(div.con$Perc_Foreign, breaks=20,main="Distribution of Contracts by Percentage Foreign Ownership", xlab="Percentage Foreign Ownership", ylab="Number of Contracts", col='blue') #missing values not included as zeros#
#Use 50% and 25% cut-off because have many more observations: 233 or 225 rather than 190#
hist(div.con$Perc_Foreign, breaks=20,main="", xlab="Percentage Foreign Ownership", ylab="Number of Contracts", col='blue')

###Histogram:  Cancellation by Year###
cancelled.contracts <- div.con[div.con$Cancelled==1,]
hist(cancelled.contracts$Cancel_date, main="Number of Cancelled Contracts by Year", xlab="Year", ylab="Number of Contracts", xlim=c(1995,2008), col='blue', breaks=18)


##Table 7.1##
	#Contract cancellation for low- and middle-income countries worldwide#
for.div.con <- div.con[div.con$X25_Foreign==1,]
for.div.con.subset <- na.omit(data.frame(for.div.con$Project_Name, for.div.con$X25_Foreign,for.div.con$Cancelled, for.div.con$WB_Rule_Law))
nrow(for.div.con.subset) #total number of contracts with >= 25% foreign ownership worldwide for which have ownership breakdowns
nrow(intlcancelled <- for.div.con.subset[for.div.con.subset$for.div.con.Cancelled==1,]) #subset of these contracts which were cancelled
as.numeric(for.div.con.subset$for.div.con.WB_Rule_Law)
mean(for.div.con.subset$for.div.con.WB_Rule_Law) #Average rule of law score for countries hosting these contracts

dom.div.con<- div.con[div.con$X25_Foreign==0,]
dom.div.con.subset <- na.omit(data.frame(dom.div.con$Project_Name, dom.div.con$X25_Foreign,dom.div.con$Cancelled, dom.div.con$WB_Rule_Law))
nrow(dom.div.con.subset) #total number of contracts with > 25% foreign ownership worldwide for which have ownership breakdowns
nrow(domcancelled <- dom.div.con.subset[dom.div.con.subset$dom.div.con.Cancelled==1,]) #subset of these contracts which were cancelled
as.numeric(dom.div.con.subset$dom.div.con.WB_Rule_Law)
mean(dom.div.con.subset$dom.div.con.WB_Rule_Law) #Average rule of law score for countries hosting these contracts

t.test(for.div.con.subset$for.div.con.Cancelled,dom.div.con.subset$dom.div.con.Cancelled)

	##Latin American subset##
LA.div.con <- div.con[div.con$Region=="Latin America and the Caribbean",]
for.div.con <- LA.div.con[LA.div.con$X25_Foreign==1,]
for.div.con.subset <- na.omit(data.frame(for.div.con$Project_Name, for.div.con$X25_Foreign,for.div.con$Cancelled, for.div.con$WB_Rule_Law))
nrow(for.div.con.subset) #total number of contracts with >= 25% foreign ownership in region for which have ownership breakdowns
nrow(intlcancelled <- for.div.con.subset[for.div.con.subset$for.div.con.Cancelled==1,]) #subset of these contracts which were cancelled
as.numeric(for.div.con.subset$for.div.con.WB_Rule_Law)
mean(for.div.con.subset$for.div.con.WB_Rule_Law) #Average rule of law score for countries hosting these contracts

dom.div.con<- LA.div.con[LA.div.con$X25_Foreign==0,]
dom.div.con.subset <- na.omit(data.frame(dom.div.con$Project_Name, dom.div.con$X25_Foreign,dom.div.con$Cancelled, dom.div.con$WB_Rule_Law))
nrow(dom.div.con.subset) #total number of contracts with < 25% foreign ownership in region for which have ownership breakdowns
nrow(domcancelled <- dom.div.con.subset[dom.div.con.subset$dom.div.con.Cancelled==1,]) #subset of these contracts which were cancelled
as.numeric(dom.div.con.subset$dom.div.con.WB_Rule_Law)
mean(dom.div.con.subset$dom.div.con.WB_Rule_Law) #Average rule of law score for countries hosting these contracts

t.test(for.div.con.subset$for.div.con.Cancelled,dom.div.con.subset$dom.div.con.Cancelled)



###RESULTS FROM TABLE 7.2###

	##Note: all analyses for the book were originally conducted using the R package "Zelig".  After the proofs for the book were submitted, Zelig stopped supporting the Cox proportional hazard model. I have therefore added R survival package commands to obtain key table results throughout this file.##

##Model 1: Results calculated using Zelig##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)
extractAIC(z.out)

	#results using standard R commands#
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)
cox.zph(s.out)


##Model 2: Results calculated using Zelig##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)
extractAIC(z.out)

	#results using standard R commands#
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)
cox.zph(s.out)

##Model 3: Results calculated using Zelig##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + national + strata(Type_PPI), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)
extractAIC(z.out)

	#results using standard R commands#
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + national + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)


##Model 4: Results calculated using Zelig##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ X25_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)
extractAIC(z.out)

	#results using standard R commands#
s.out <- coxph(Surv(Lifespan, Cancelled) ~ X25_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)


##Model 5: Results using Zelig##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Multi_Part + strata(Type_PPI), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)
extractAIC(z.out)

	#results using standard R commands#
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Multi_Part + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)


##Table 7.2 Results Omitting Argentina##
div.con.noAR <- div.con[div.con$Country!="Argentina",]

##Model 1: Half Foreign less but still significant, GDPpc more significant##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI), model="coxph", data=div.con.noAR, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con.noAR)
summary(s.out)
extractAIC(s.out)

##Model 2: Half foreign less but still significant##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI), model="coxph", data=div.con.noAR, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con.noAR)
summary(s.out)
extractAIC(s.out)

##Model 3: Half foreign less but still significant##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + national + strata(Type_PPI), model="coxph", data=div.con.noAR, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + national + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con.noAR)
summary(s.out)
extractAIC(s.out)

##Model 4: 25% Foreign less but still significant##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ X25_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI), model="coxph", data=div.con.noAR, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ X25_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con.noAR)
summary(s.out)
extractAIC(s.out)

##Model 5: Half foreign less but still significant##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Multi_Part + strata(Type_PPI), model="coxph", data=div.con.noAR, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Multi_Part + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con.noAR)
summary(s.out)
extractAIC(s.out)

##Result for Table 7.2 Stratified by Region##

##Model 1: Results roughly the same##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + strata(Region), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + strata(Region) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

##Model 2: Results roughly the same##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + strata(Region), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + strata(Region) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

##Model 3: Results roughly the same, though polity becomes significant##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + national + strata(Type_PPI) + strata(Region), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + national + strata(Type_PPI) + strata(Region) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

##Model 4: Results roughly the same##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ X25_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + strata(Region), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ X25_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + strata(Region) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

##Model 5: Results roughly the same, though Half_Foreign loses significance here##
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Multi_Part + strata(Type_PPI) + strata(Region), model="coxph", data=div.con, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Multi_Part + strata(Type_PPI) + strata(Region) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

###Results when stratify by Country### (note that eliminate the country-level variables because stratifying by country)
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + strata(Country) + strata(Type_PPI), model="coxph", data=div.con, robust=TRUE) ##p=0.11##
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + strata(Country) + strata(Type_PPI) + strata(Region), robust=TRUE, data=div.con)
summary(s.out)

z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + strata(Country), model="coxph", data=div.con, robust=TRUE) ##p=0.09##
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + strata(Country) + strata(Region), robust=TRUE, data=div.con)
summary(s.out)

##Results when stratify by income level##

div.con$Income_Level=0
##have to eliminate Cuba because of the missing income value##
div.con.noCuba <- div.con[div.con$Country!="Cuba",]
for (i in 1:nrow(div.con.noCuba)){
	if (div.con.noCuba$GDPpc1991[i]<976) 
	div.con.noCuba$Income_Level[i] <- "Low Income"
	if (div.con.noCuba$GDPpc1991[i]>975)
	div.con.noCuba$Income_Level[i] <- "Middle Income"
	if (div.con.noCuba$GDPpc1991[i]>3855)
	div.con.noCuba$Income_Level[i] <- "Upper Middle Income"
	}
	
	#Model 1
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + strata(Income_Level) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

	#Model 2
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + strata(Income_Level) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

	#Model 3
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + national + strata(Type_PPI) + strata(Income_Level) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

	#Model 4
s.out <- coxph(Surv(Lifespan, Cancelled) ~ X25_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + strata(Income_Level) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)

	#Model 5
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Multi_Part + strata(Type_PPI) + strata(Income_Level) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)



####First Differences calculated using Zelig####

attach(div.con)
div.con.subset <- data.frame(Project_Name, Lifespan, Cancelled, Half_Foreign, GDPpc1991, WB_Rule_Law, Polity, Country,Type_PPI)
div.con.subset <- na.omit(div.con.subset)
detach(div.con)
##Missing values will interfere with simulations and generate error messages regarding subscript being out of bounds; therefore create subset of data for just this regression and eliminate missing values###

z.out1 <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity, model="coxph", robust=TRUE, data=div.con.subset, cluster="Country") 
summary(z.out1)
extractAIC(z.out1)
x.low1 <- setx(z.out1, Half_Foreign=0, strata="Type_PPI=Concession") 
x.high1 <- setx(z.out1, Half_Foreign=1, strata="Type_PPI=Concession")
s.out1 <- sim(z.out1, x = x.low1, x1 = x.high1)
summary(s.out1)


###DF Betas###
#use same data subset as above (div.con.subset) as diagnostics do not work with missing observations#
attach(div.con)
div.con.subset <- na.omit(data.frame(Project_Name, Lifespan, Half_Foreign, GDPpc1991, Polity, Country, Type_PPI, Cancelled, WB_Rule_Law))
detach(div.con)

attach(div.con.subset)
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con.subset)
par(mfrow=c(2,2))
rr <- resid(s.out, type='dfbeta')

##Observations and their Influence on the property rights variable##

plot(div.con.subset$WB_Rule_Law, rr[,3], xlab="Rule of Law", ylab="Influence for Rule of Law Variable") ##note that have to adjust column of residual matrix if alter regression##
identify(div.con.subset$WB_Rule_Law, rr[,3])

##Observations and their Influence on the foreign ownership variable##
plot(div.con.subset$Half_Foreign, rr[,1], xlab="Half Foreign", ylab="Influence for Foreign Ownership Variable")
identify(div.con.subset$Half_Foreign, rr[,1])


	
##Results for Democracies##

dems <- div.con[div.con$Polity>0,]
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI), model="coxph", data=dems, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + cluster(Country), robust=TRUE, data=dems)
summary(s.out)
extractAIC(s.out)

dems2 <- div.con[div.con$Polity>6,]
z.out <- zelig(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI), model="coxph", data=dems, robust=TRUE, cluster="Country")
summary(z.out)

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + cluster(Country), robust=TRUE, data=dems2)
summary(s.out)
extractAIC(s.out)


##Results for all types of contracts: concessions, divestitures, management & lease, and greenfield##

	#Model 1
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + strata(Type_PPI) + cluster(Country), robust=TRUE, data=foreign_dom)
summary(s.out)
extractAIC(s.out)

	#Model 2
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + cluster(Country), robust=TRUE, data=foreign_dom)
summary(s.out)
extractAIC(s.out)

	#Model 3
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + national + strata(Type_PPI)  + cluster(Country), robust=TRUE, data=foreign_dom)
summary(s.out)
extractAIC(s.out)

	#Model 4
s.out <- coxph(Surv(Lifespan, Cancelled) ~ X25_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Size_Cat + strata(Type_PPI) + cluster(Country), robust=TRUE, data=foreign_dom)
summary(s.out)
extractAIC(s.out)

	#Model 5
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + WB_Rule_Law + Polity + Multi_Part + strata(Type_PPI) + cluster(Country), robust=TRUE, data=foreign_dom)
summary(s.out)
extractAIC(s.out)


##Results when substitute X for WB rule of law measure so as to include WB state effectiveness score# (p. 201) 

s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + GDPpc1991 + Prop_Rights + Polity + Gov.Effectiveness + strata(Type_PPI) + cluster(Country), robust=TRUE, data=div.con)
summary(s.out)
extractAIC(s.out)
cox.zph(s.out)


##Graphs of the Survival Curves##
s.out <- coxph(Surv(Lifespan, Cancelled) ~ Half_Foreign + Polity + WB_Rule_Law + GDPpc1991, data=div.con, robust=TRUE)
summary(survfit(s.out))
plot(survfit(s.out, conf.type = "log-log"))

par(mfrow=c(1,2))
plot(survfit(s.out, newdata=data.frame(Half_Foreign=1, Polity=1.17, WB_Rule_Law=-0.02, GDPpc1991=3533), conf.type = "log-log"), xlab="Year of Contract", ylab="Survival", main="Survival for Foreign Investors")

plot(survfit(s.out, newdata=data.frame(Half_Foreign=0, Polity=1.17, WB_Rule_Law=-0.02, GDPpc1991=3533), conf.type = "log-log"), xlab="Year of Contract", ylab="Survival", main="Survival for Domestic Investors")


###Variable profiles (online appendix, table A.3)###
mean(na.omit(div.con$Half_Foreign))
sd(na.omit(div.con$Half_Foreign))

mean(na.omit(div.con$X25_Foreign))
sd(na.omit(div.con$X25_Foreign))

min(na.omit(div.con$GDPpc1991))
max(na.omit(div.con$GDPpc1991))
mean(na.omit(div.con$GDPpc1991))
sd(na.omit(div.con$GDPpc1991))

min(na.omit(div.con$Polity))
max(na.omit(div.con$Polity))
mean(na.omit(div.con$Polity))
sd(na.omit(div.con$Polity))

min(na.omit(div.con$WB_Rule_Law))
max(na.omit(div.con$WB_Rule_Law))
mean(na.omit(div.con$WB_Rule_Law))
sd(na.omit(div.con$WB_Rule_Law))

min(na.omit(div.con$Multi_Part))
max(na.omit(div.con$Multi_Part))
mean(na.omit(div.con$Multi_Part))
sd(na.omit(div.con$Multi_Part))

min(na.omit(div.con$Joint_Venture))
max(na.omit(div.con$Joint_Venture))
mean(na.omit(div.con$Joint_Venture))
sd(na.omit(div.con$Joint_Venture))

###Balance Chart  (Online appendix, table A.4)###

for.div.con <- div.con[div.con$Half_Foreign==1,]
dom.div.con<- div.con[div.con$Half_Foreign==0,]
mean(na.omit(for.div.con$GDPpc1991))
mean(na.omit(dom.div.con$GDPpc1991))
sd(na.omit(for.div.con$GDPpc1991))
sd(na.omit(dom.div.con$GDPpc1991))

mean(na.omit(for.div.con$WB_Rule_Law))
mean(na.omit(dom.div.con$WB_Rule_Law))
sd(na.omit(for.div.con$WB_Rule_Law))
sd(na.omit(dom.div.con$WB_Rule_Law))

mean(na.omit(for.div.con$Polity))
mean(na.omit(dom.div.con$Polity))
sd(na.omit(for.div.con$Polity))
sd(na.omit(dom.div.con$Polity))

mean(na.omit(for.div.con$Size_Cat))
mean(na.omit(dom.div.con$Size_Cat))
sd(na.omit(for.div.con$Size_Cat))
sd(na.omit(dom.div.con$Size_Cat))

mean(na.omit(for.div.con$national))
mean(na.omit(dom.div.con$nation))
sd(na.omit(for.div.con$national))
sd(na.omit(dom.div.con$nation))

mean(na.omit(for.div.con$Multi_Part))
mean(na.omit(dom.div.con$Multi_Part))
sd(na.omit(for.div.con$Multi_Part))
sd(na.omit(dom.div.con$Multi_Part))


	